package com.itheima.mapper.admin;

import com.itheima.admin.employeepojo.Employee;
import com.itheima.admin.employeepojo.vo.EmployeePageVo;
import com.itheima.admin.employeepojo.vo.EmployeeByIdVo;
import com.itheima.admin.employeepojo.Login;
import org.apache.ibatis.annotations.*;

import java.util.List;


/**
 * @author wuzhiyong
 */
@Mapper
public interface EmployeeMapper {


    /**
     * 登陆
     * @param employee employee
     * @return login
     */
    Login login(Employee employee);

    /**
     * 分页查询
     * @param name name
     * @param startIndex startIndex
     * @param pageSize pageSize
     * @return List<EmployeePageData>
     */
    List<EmployeePageVo> selectPage(String name, Integer startIndex, Integer pageSize);
    /**
     * 分页-获取总条数
     * @return 条数
     */
    @Select("select count(*)from admin_employee")
    int selectAllEmployee();

    /**
     * 根据id查询
     * @param id id
     * @return  EmployeeById
     */
    EmployeeByIdVo selectByIdEmployee(@Param("id") String id);

    /**
     * 添加员工
     * @param employee employee
     * @return 条数
     */
    @Insert("insert into reggie.admin_employee(username,name,  phone, sex, id_number)values (#{username},#{name},#{phone},#{sex},#{idNumber})")
    int insertEmployee(Employee employee);
    /**
     * 用于判断用户是否存在
     * @param username username
     * @return Employee
     */
    @Select("select username from reggie.admin_employee where username=#{username}")
    String selectByUsername(String username);

    /**
     * 启用/禁用/修改
     * @param employee employee
     * @return 条数
     */
    int updateEmployee(Employee employee);


}
